<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title>后台管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/lay/layui/index.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body" style="padding: 15px;">
        <form name="addItem" method="post" lay-filter="component-form-group" class="layui-form">
          <input type="hidden" value="<!--{$datainfo.id}-->" name="id">
          <input type="hidden" value="<!--{$datainfo.aid}-->" name="aid">
          <!--{if $datainfo.status >1 }-->
          <label class="layui-form-label">订单已完成</label>

          <div class="layui-form-item">
            <label class="layui-form-label">更换系数</label>
            <div class="layui-inline">
              <input type="text" name="ratio" lay-verify="ratio" value="<!--{$datainfo.ratio}-->" placeholder="请输入" autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-inline">
             
            </div>
          </div>
          <!--{else}-->
          <label class="layui-form-label">订单未完成</label>
          <!--{/if}-->
        <div class="layui-form-item layui-layout-admin">
            <div class="layui-footer" style="left: 0;">
              <button  class="layui-btn" type="button" id="resettle" lay-submit lay-filter="resettle">重算订单</button>
              <button type="reset" id='reset' class="layui-btn layui-btn-primary">重置</button>
              <button type="button" class="layui-btn layui-btn-primary" onClick="xadmin.close();" >返回</button>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
<script src="/static/lay/layui/layui.js"></script>
  <script type="text/javascript">
    layui.config({
     base: '/static/lay/' //静态资源所在路径
   }).extend({
     xadmin: 'lib/xadmin' //弹窗
   }).use(['jquery', 'layer','xadmin', 'form'], function(){
    var form = layui.form;
    form.render(null, 'component-form-group');

    form.verify({
      ratio: function(value){
        if(value.length < 1){
          return '参数不能为空';
        }else{
          if(!(/^\d{1,9}(\.\d{1,3})?$/).test(value)){
            return '参数只能为数字';
          }
        }
      }    
    });
    form.on('submit(resettle)', function (data) {
          $('#resettle').attr("disabled",true);
          $('#resettle').addClass('layui-btn-disabled');
          $.post('resettle',data.field,function(res){
              if(res.code == 200){
                  layer.msg(res.msg);
                  setTimeout(() => {
                      window.parent.location.reload();
                      xadmin.close();
                  }, 1000);
              }else{
                 layer.msg(res.msg);
              }
          })
        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });
    //重置按钮，可以提交失败的时候再次提交
    $('#reset').click(function(){
        $('#resettle').removeAttr("disabled");
        $('#resettle').removeClass('layui-btn-disabled');
    });
  });
  </script>
</body>
</html>

